/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package BUS;
import DTO.*;
import DAO.*;
import java.sql.SQLException;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
/**
 *
 * @author ldtung_it
 */
public class FileAttachedBUS {
    public static int add(FileAttachedDTO fileAttached){
        String error = "";
        if(fileAttached.get_pathFileAttached() == null){
            error += "  File path must not null\n";
        }
        if(!CheckData.isNum(fileAttached.get_idMail())){
            error += "  IDMail must be number\n";
        }
        if(error.length() != 0){
            JOptionPane.showMessageDialog(null, error);
            return 0;
        }
        try {
            FileAttachedDAO.add(fileAttached);
            return 1;
        } catch (SQLException ex) {
           
        }
        
        return 0;
    }
}
